<script type="text/javascript">
	$(document).ready(function() {
		$("#scholarlist").tablesorter({
			widthFixed: true,
			widgets: ['zebra']
		}).tablesorterPager({
			container: $(".pager")
		});
	});
</script>

<div id="main-content" class="prepend-1 span-19 last">
<?php 
	if ($applystatus != FALSE) {
		echo '<span class="info">'.$applystatus.'</span><br /><br />';
	}
?>
	<h3>Daftar Beasiswa Ditawarkan</h3>
	<table id="scholarlist">
	<thead>
		<tr>
			<th>Nama Beasiswa</th>
			<th width="120">Awal Periode</th>
			<th width="120">Akhir Periode</th>
			<th width="120">Batas Pendaftaran</th>
			<th>Keterangan</th>
			<th width="80">Status</th>
			<th width="80">Operasi</th>
		</tr>
	</thead>
	<tfoot>
		<?php echo $pager; ?>
	</tfoot>
	<tbody>
<?php 
	if ($scholarships == NULL) :
?>
		<tr>
			<td align="center" colspan="7">
				<span class="info">Tidak ada beasiswa ditawarkan.</span>
			</td>
		</tr>
<?php 
	else : 
		foreach ($scholarships as $scholarship) :
?>
		<tr>
			<td><?php echo $scholarship->name; ?></td>
			<td align="center"><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_start)); ?></td>
			<td align="center"><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_end)); ?></td>
			<td align="center"><?php echo date(DAY_FORMAT, strtotime($scholarship->deadline)); ?></td>
			<td><?php echo $scholarship->details; ?></td>
			<td align="center">
				<span class="info">
<?php
			if ($scholarship->status != NULL && $scholarship->status != 'ditawarkan') {
				echo $scholarship->status;
			} else if (strtotime($scholarship->deadline) < strtotime(date('Y-m-d'))) {
				echo '<span class="error">Lewat Deadline</span>';
			} else if ($scholarship->status == NULL) { 
				echo "dibuka";
			} else {
				echo $scholarship->status;
			}
			$flag = TRUE;
			if ($scholarship->status == 'tidak terverifikasi' || $scholarship->status == 'terverifikasi' || $scholarship->status == 'mendaftar' || $scholarship->status == 'ditolak') {
				$flag = FALSE;
			}
?>
				</span>
			</td>
			<td align="center">
<?php 
			if ($flag == FALSE) {
				echo anchor('mahasiswa/scholar/detail/'.$scholarship->id, 'Detil Pendaftaran');
			} else if (strtotime($scholarship->deadline) < strtotime(date('Y-m-d'))) {
				echo '-';
			} else {
				echo anchor('mahasiswa/scholar/apply/'.$scholarship->id, 'Daftar'); 
			}
?>
			</td>
		</tr>
<?php 
		endforeach;
	endif;
?>
	</tbody>
	</table>
	<div class="clear"><?php echo nbs(); ?></div>
</div>
